package com.file.controller;

import com.file.service.UploadService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * Json
 * Created by hui on 2017/12/4.
 */

@Controller
public class UploadController {
    private Logger logger = Logger.getLogger(UploadController.class);

    @Autowired
    private UploadService uploadService;

    /*
     *  http://localhost:8099/upload
     */
    @RequestMapping("/upload")
    public String greeting() {
        logger.info("upload");
        return "/upload/upload";
    }

    @RequestMapping("/upload/submit")
    public void doPost(HttpServletRequest request, HttpServletResponse response,Model model) {
        logger.info("upload/submit");
        try {
            uploadService.doPost(request,response);
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
